package cn.com.jslh.boarpro.util;

import android.content.Context;
import android.content.Intent;

/**
 * 作者：周洲 on 2017/3/22 11:23
 * <p>
 * 邮箱：double0zhou@126.com
 */

public class StartActivityUtil {
//        new StartActivityUtil.Builder(this,MainActivity.class).build();
    private Context context;
    private Class cls;
    private Intent intent;

    private StartActivityUtil(){};

    private StartActivityUtil(Builder builder){
        this.context = builder.context;
        this.cls = builder.cls;
        this.intent =builder.intent;
        context.startActivity(intent);
    }


    public static class Builder{
        private Context context;
        private Class cls;
        private Intent intent;

        /**
         *
         * @param cxt context
         * @param cls 指向Activity
         */
        public Builder(Context cxt,Class cls){
            this.context = cxt;
            this.cls = cls;
            intent = new Intent(this.context,this.cls);
        }

        public Builder addValue(String key,String value){
            intent.putExtra(key,value);
            return this;
        }

        public Builder addValue(String key,int value){
            intent.putExtra(key,value);
            return this;
        }
        public Builder setFlags(int flags){
            intent.setFlags(flags);
            return this;
        }
        public StartActivityUtil build(){
            return new StartActivityUtil(this);
        }
    }
}
